// packageF/others/customerCenter/component/userDetail/memberInfo/memberInfo.js
const app = getApp();
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    memberId: {
      type: null
    },
    userMember: {
      type: null
    },
    keywork: {
      type: null
    },
  },

  /**
   * 组件的初始数据
   */
  data: {
    strUrl: 'plugin.wechat-chat-sidebar.frontend.controller.customer.customer.get-user-info',
    getConfig: {
      client: 'work',
      type: 17
    }, //企业微信公共参数
    userInfo: '',
    memberInfo: '',
    bankCard: {},
  },
  lifetimes: {
    attached() {
      console.log(this.data.keywork)
      this.getData();
    }
  },
  /**
   * 组件的方法列表
   */
  methods: {
    async getData() {
      if (this.data.keywork == 'customer') {
        //客户中心
        this.setData({
          userInfo: this.data.userMember,
          memberInfo: this.data.userMember,
          bankCard: this.data.userMember.bank_card
        })
        return
      }
      try {
        let urlStr = app.getNetAddresss(this.data.strUrl);
        app._postNetWork({
          url: urlStr,
          data: { ...this.data.getConfig, ...this.data.memberId },
          success: (resdata) => {
            let res = resdata.data
            if (res.result == 1) {
              this.setData({
                userInfo: res.data,
                memberInfo: res.data.yz_member,
                bankCard: res.data.bankCard
              })
            } else {
              wx.showToast({
                icon: 'none',
                title: res.msg,
                duration: 1500
              });
            }
          },
          fail: function (res) {
            console.log(res);
          }
        });
      } catch (err) {
        console.log("接口报错::", err);
      }
    }
  }
})